package cn.iocoder.yudao.module.handguard.dal.mysql.userfollowup;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.handguard.dal.dataobject.userfollowup.UserFollowUpDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.handguard.controller.app.userfollowup.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 业务员/权证跟进记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface UserFollowUpMapper extends BaseMapperX<UserFollowUpDO> {

    default PageResult<UserFollowUpDO> selectPage(UserFollowUpPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserFollowUpDO>()
                .eqIfPresent(UserFollowUpDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserFollowUpDO::getFollowUpId, reqVO.getFollowUpId())
                .eqIfPresent(UserFollowUpDO::getApplicationId, reqVO.getApplicationId())
                .betweenIfPresent(UserFollowUpDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserFollowUpDO::getId));
    }

    default List<UserFollowUpDO> selectList(UserFollowUpExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<UserFollowUpDO>()
                .eqIfPresent(UserFollowUpDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserFollowUpDO::getFollowUpId, reqVO.getFollowUpId())
                .eqIfPresent(UserFollowUpDO::getApplicationId, reqVO.getApplicationId())
                .betweenIfPresent(UserFollowUpDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserFollowUpDO::getId));
    }

    int getMyFollowUpUser(@Param("userId") Long userId,@Param("userType") Integer userType);

    List<UserFollowUpDO> getMyMonthFollowUpUser(@Param("userId") Long userId);

    List<UserFollowUpDO> getMonthFollowUpList(@Param("userId") Long userId);

    Integer getAWUpUser(@Param("userId")Long userId);

    int deleteByOrderId(@Param("orderId")Long orderId,@Param("userId")Long userId);
}
